<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: XiangLang15078435014
  Date: 2021/11/1
  Time: 20:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
    <%--1.声明类属性--%>
    <%!
      private String name;
      private static Map<String, Object> map;

      Map<Integer, String> map1 =new HashMap<Integer,String>();
    %>
    <%--2.声明类方法--%>
    <%!
      public int sum() {
        return 12;
      }
    %>
    <%--3.声明静态代码块--%>
    <%!
      static {
        map = new HashMap<String, Object>();
        map.put("key1", "value1");
      }


    %>

    <%=sum()%>

    <br>
    <%
      out.write(String.valueOf(map.get("key1"))+"<br>");

      map1.put(1,"你好Kevin老师");
      map1.put(2,"好嘞！");
      out.println(map1);

      //或者这样声明
      Map<String,String> hashMap = new HashMap<>();
    %>
  </body>
</html>
